<template>
  <div class="analysisContent">
    <div class="content">
      <div class="realTimeData">
        <div class="monitorList">
          <tableList
            :hisDataList="tableData"
            :factorField="factorField"
            :factorStatus="factorStatus"
            :height="tableHeight"
            :dataTypeShow="dataTypeShow"
          ></tableList>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import tableList from "@/components/tableList.vue";
export default {
  name: "analysisContent",
  props: ["dataTypeShow", "monitorData"],
  components: {
    tableList,
  },
  computed: {
    ...mapGetters({
      userInfo: "getUserInfo",
    }),
    tableData() {
      if (this.dataTypeShow === "hour") {
        let arr = this.monitorData.outletDataList.filter((data)=>{
          return (data.stationType == 1 && data.statisticType === 0) || data.stationType == 2 || ( data.stationType == 3 && ( data.statisticType === 0 || data.statisticType === 1))
        })
        return [...this.monitorData.data,...arr];
      } else {
        let arr = this.monitorData.outletDataList.filter((data)=>{
          return (data.stationType == 1 && data.statisticType === 1) || (data.stationType == 3 && (data.statisticType === 2 || data.statisticType ===3)) 
        })
        return [...this.monitorData.oneHourData,...arr];
      }
    },
    factorField() {
      if (this.dataTypeShow === "hour") {
        return this.monitorData.factorField;
      } else {
        return [
          {
            devStatus: "pH",
            factorLimit: "±0.1L",
            label: "pH",
            prop: "ph",
            standardValue: "6.5~9.5",
          },
          {
            devStatus: "CODcr",
            factorLimit: "10L",
            label: "CODcr mg/L",
            prop: "COD",
            standardValue: 500,
          },
          {
            devStatus: "氨氮",
            factorLimit: "0.05L",
            label: "氨氮 mg/L",
            prop: "ammoniaNitrogen",
            standardValue: 45,
          },
          {
            devStatus: "总磷",
            factorLimit: "0.01L",
            label: "总磷 mg/L",
            prop: "phosphorus",
            standardValue: 8,
          },
          {
            devStatus: "总铜",
            factorLimit: "0.02L",
            label: "总铜 mg/L",
            prop: "cuprum",
            standardValue: 2,
          },
          {
            devStatus: "总镍",
            factorLimit: "0.02L",
            label: "总镍 mg/L",
            prop: "nickel",
            standardValue: 1,
          },
          {
            devStatus: "总氮",
            factorLimit: "0.05L",
            label: "总氮 mg/L",
            prop: "nitrogen",
            standardValue: 70,
          },
          {
            devStatus: "瞬时流量",
            factorLimit: "0.02L",
            label: "瞬时流量 m³/s",
            prop: "realFlow",
            standardValue: 1,
          },
          {
            devStatus: "累积流量",
            factorLimit: "0.02L",
            label: "累积流量 10⁴m³/h",
            prop: "cumulativeFlow",
            standardValue: 1,
          },
        ];
      }
    },
    factorStatus() {
      if (this.dataTypeShow === "hour") {
        return this.monitorData.factorStatus;
      } else {
        return {
          CODcr: "deviceCod",
          pH: "devicePh",
          总镍: "deviceNi",
          总铜: "deviceCu",
          总磷: "deviceP",
          氨氮: "deviceAn",
          总氮: "deviceN",
          瞬时流量: "deviceRf",
          累积流量: "deviceCf",
        };
      }
    },
    tableHeight() {
      return document.body.clientHeight - 240 + "px";
    },
  },
};
</script>

<style scoped>
.analysisContent {
  width: 100%;
  height: 100%;
}
.taps {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 30px;
  line-height: 30px;
}
.taps .tapsItem {
  width: 23%;
  height: 100%;
  line-height: inherit;
  text-align: center;
  background-color: #47acff;
  color: #fff;
  border-top-right-radius: 4px;
  border-top-left-radius: 4px;
  cursor: pointer;
  transition: 0.25s ease;
}
.taps .tapsItem.active {
  background-color: #fff;
  color: #47acff;
}
.taps .tapsItem .tapsIcon {
  width: 14px;
  height: auto;
  vertical-align: middle;
  margin-right: 6px;
}

.content {
  box-sizing: border-box;
  height: calc(100%);
  overflow: auto;
  background-color: #fff;
  padding: 12px;
  padding-bottom: 0px;
}
.content .realTimeData,
.realTimeData .monitorList {
  height: 100%;
}

/* 修改滚动条样式 */
.content::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.content::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}
.content::-webkit-scrollbar-thumb {
  background: #ccdaf3;
  border-radius: 10px;
}
.content::-webkit-scrollbar-thumb:hover {
  background: #789ddc;
}

.unitContent {
}
.unitContent .unitItem {
  display: inline-block;
  width: 33%;
  line-height: 35px;
}
.unitContent .unitItem .laber {
  font-weight: bold;
}
.unitContent .factor {
  width: 80%;
  margin: 22px auto;
  text-align: center;
}

.canClick {
  cursor: pointer;
}
.canClick span {
  text-decoration: underline;
}
</style>
